﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Zgq.CommonTools
{
    /// <summary>
    /// 视图关联特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
    public class C5ViewClassAttribute : Attribute
    {
        /// <summary>
        /// 带参构造函数
        /// </summary>
        /// <param name="reltag">标记名</param>
        public C5ViewClassAttribute(string reltag)
        {
            this.RelTag = reltag;
        }

        /// <summary>
        /// 标记名
        /// </summary>
        public string RelTag { get; set; }

        /// <summary>
        /// 视图主表名
        /// </summary>
        public string BaseTable { get; set; }

        /// <summary>
        /// 全局字符串默认值或者函数名称
        /// </summary>
        public string IsNullStrOrFun { get; set; }

        /// <summary>
        /// 全局数字类型默认值
        /// </summary>
        public int IsNullInt { get; set; }

        /// <summary>
        /// 主表关联字段
        /// </summary>
        public string BaseFiled { get; set; }

        /// <summary>
        /// 关联表表名
        /// </summary>
        public string RelTable { get; set; }

        /// <summary>
        /// 关联表的关联字段
        /// </summary>
        public string RelFiled { get; set; }

        /// <summary>
        /// 连接类型（LEFT、RIGHT、INNER）
        /// </summary>
        public int JoinType { get; set; }

        /// <summary>
        /// 关联SQL语句(可追加条件)
        /// </summary>
        public string JoinOther { get; set; }
    }

    public enum JoinType
    {
        /// <summary>
        /// 左连接
        /// </summary>
        Left = 1,

        /// <summary>
        /// 右连接
        /// </summary>
        Right = 2,

        /// <summary>
        /// 内连接
        /// </summary>
        Inner = 3
    }
}
